package com.lyj.sc.tianchi;

/**
 * @program: code-random
 * @description: 删除排序链表的重复元素
 * @author: lyj
 * @create: 2022-07-14 15:32
 * @version: 1.0
 * @Modifier By:
 **/
public class test3 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode dummynode  = new ListNode(0,head);
        ListNode cur = dummynode;
        while(cur.next!=null && cur.next.next!=null){
            if(cur.next.val==cur.next.next.val){
                int x = cur.next.val;
                while(cur.next!=null && x==cur.next.val){
                    cur.next=cur.next.next;
                }
            }else{
                cur=cur.next;
            }
        }
        return dummynode.next;
    }
}
